<template>
  <view class="page-container">
    <uni-card :is-shadow="false" is-full class="card-container">
    
      <view class="container">
		  <uni-title style="margin-left: 18px;" type="h2" title="账号" ></uni-title>
        <uni-list>
			
          <uni-list-item  :to="`./info/index`" showArrow  showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="个人信息管理" rightText="编辑用户信息" />
          <uni-list-item  :to="`./order/index`" showArrow  showExtraIcon="true" :extraIcon="{type: 'bars'}" title="查询工单" rightText="查询账号中已完成/未完成工单" />
        </uni-list>
		
		
		<uni-title style="margin-left: 18px;margin-top: 40px;" type="h2" title="通用" ></uni-title>
		<uni-list>
			
		  <uni-list-item  :to="`./edit`" showArrow  showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="通用设置" rightText="暂未开放" />
		</uni-list>
      </view>
    </uni-card>
  </view>
</template>

<script>
import { getUserProfile } from "@/api/system/user"

export default {
  data() {
    return {
      user: {
        avatar: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg' // 确保有默认值，防止渲染时未定义
      },
      roleGroup: "",
      postGroup: ""
    }
  },
  onLoad() {
    this.getUser()
  },
  computed: {
    avatar() {
      return this.$store.state.user.avatar
    },
    windowHeight() {
      return uni.getSystemInfoSync().windowHeight - 50
    }
  },
  methods: {
	 
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data // 注意这里可能需要根据实际返回数据结构调整
        this.roleGroup = response.roleGroup
        this.postGroup = response.postGroup
      })
    },
    handleUploadAvatar() {
      // 处理上传头像的逻辑
      uni.chooseImage({
        count: 1, // 默认9
        sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
        success: (res) => {
          const tempFilePaths = res.tempFilePaths;
          console.log(tempFilePaths);
          // 这里可以调用上传接口将tempFilePaths中的文件路径发送给服务器
          // 例如：
          // uploadAvatar(tempFilePaths[0]).then(response => {
          //   this.user.avatar = response.data.url; // 更新用户头像URL
          // });
        }
      });
    }
  }
}
</script>

<style lang="scss">
page {
  background-color: #f7f7f7;
}

/* 外层容器 */
.page-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  box-sizing: border-box;
  margin: 0;
  padding: 15px;
}

/* uni-card 容器 */
.card-container {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* 头像部分 */
.profile-section {
  text-align: center;
  margin-bottom: 15px;
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin: 0 auto;
}

.upload-btn {
  margin-top: 10px;
  background-color: #1aad19;
  color: white;
  border: none;
  width: 140px;
  height: 40px;
  font-size: 17px;
  cursor: pointer;
  border-radius: 15px;
}

/* 内层容器 */
.container {
  flex-grow: 1;
  display: flex;
 
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}
</style>